#include "libMediaRtmp.h"
#include "libMediaPushWorker.h"


LIBMEDIARTMP_API void* MediaRtmp_Create()
{
    libMediaPushWorker* pPusher = new libMediaPushWorker();
    return (void*)pPusher;
}

LIBMEDIARTMP_API void MediaRtmp_SetSPSAndPPS(void* pPushHandle, unsigned char*sps, long&spslen, unsigned char*pps, long&ppslen)
{
    if (!pPushHandle)
    {
        return;
    }
    libMediaPushWorker* pPusher = (libMediaPushWorker*)pPushHandle;
    pPusher->Set_SPSAndPPS(sps, spslen, pps, ppslen);
}

LIBMEDIARTMP_API void MediaRtmp_Init(void* pPushHandle, const char* strUrl)
{
    if (!pPushHandle)
    {
        return;
    }
    libMediaPushWorker* pPusher = (libMediaPushWorker*)pPushHandle;
    pPusher->Init(strUrl);
}

LIBMEDIARTMP_API void MediaRtmp_PushCapData(void* pPushHandle, MediaType nType, char* pBuff, int nBuffLen, bool bKeyFrame)
{
    if (!pPushHandle)
    {
        return;
    }
    libMediaPushWorker* pPusher = (libMediaPushWorker*)pPushHandle;
    pPusher->MediaCapData_CB(nType, pBuff, nBuffLen, bKeyFrame);
}

LIBMEDIARTMP_API void MediaRtmp_Release(void* pPushHandle)
{
    if (!pPushHandle)
    {
        return;
    }
    libMediaPushWorker* pPusher = (libMediaPushWorker*)pPushHandle;
    pPusher->Release();
    delete pPusher;
    pPushHandle = NULL;
}
